package cc.autoapi.pucong.auto.flow.core.flow.execNode.exec;

import cc.autoapi.pucong.auto.flow.core.flow.execNode.eventBus.ISubscriber;
import cc.autoapi.pucong.auto.flow.core.flow.execNode.eventBus.SubscribePublish;
import cc.autoapi.pucong.auto.flow.core.flow.execNode.exec.handler.ProcessExecApiHandler;
import cc.autoapi.pucong.auto.flow.core.flow.execNode.exec.handler.ProcessExecLogHandler;
import cc.autoapi.pucong.auto.flow.core.flow.execNode.exec.handler.ProcessExecNodeHandler;
import cc.autoapi.pucong.auto.flow.core.flow.execNode.exec.publish.ProcessExecApiPublish;
import cc.autoapi.pucong.auto.flow.core.flow.execNode.exec.publish.ProcessExecLogPublish;
import cc.autoapi.pucong.auto.flow.core.flow.execNode.exec.publish.ProcessExecNodePublish;

public class AutoFlow {

    public static ProcessExecApiPublish apiPublish = new ProcessExecApiPublish();

    public static ProcessExecNodePublish nodeExecPublish = new ProcessExecNodePublish();

    public static ProcessExecLogPublish nodeLogPublish = new ProcessExecLogPublish();


    public AutoFlow() {
        ISubscriber apiHandler = new ProcessExecApiHandler();
        ISubscriber logHandler = new ProcessExecLogHandler();
        ISubscriber nodeHandler = new ProcessExecNodeHandler();
        SubscribePublish.getSubscribePublish().subcribe(apiHandler);
        SubscribePublish.getSubscribePublish().subcribe(logHandler);
        SubscribePublish.getSubscribePublish().subcribe(nodeHandler);
    }

    /**
     * 注册到订阅器
     */
    public void registry(ISubscriber subscriber) {
        SubscribePublish.getSubscribePublish().subcribe(subscriber);
    }

    /**
     * 退订
     * 默认实现
     */
    public void unSubcribe(ISubscriber subscriber) {
        SubscribePublish.getSubscribePublish().unSubcribe(subscriber);
    }

}
